package demo1;

public class Test1 {
    public static void func(int a) throws ArithmeticException,NullPointerException{
        if(a == 0) {
            throw new ArithmeticException("除数为零，算数异常");
        }
        int b = 40 / a;
        System.out.println(b);
        int[] array = null;
        if(array == null) {
            throw new NullPointerException("空指针异常");
        }
        System.out.println(array[1]);
    }
    public static void main(String[] args) {
        int a = 2;
        func(a);
    }
}
